<ui:composition template="/WEB-INF/templates/main-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="sidebar">
	<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>
	<ui:define name="content">
	
	   <h:panelGroup style="width:100%;text-align:center;">
		 <h:outputText value="Project perdiem expenses" styleClass="outputTextTitle" style="margin-left:4px;"/>
		</h:panelGroup>
		<h:form >
		<p:focus ></p:focus>
		<p:growl id="growl"></p:growl>
		
		<h:panelGrid columns="3"  columnClasses="gridCellMiddleLeftAligned, gridCellMiddleRightAligned">
					
			<h:outputLabel value="Select" />
		    <h:outputLabel value=":" />		
			<p:menuButton value="#{projectPerdiemsBean.selectedButton}">
				
				<p:menuitem value="Create Project Perdiems" actionListener="#{projectPerdiemsBean.buttonChangeListner}" update="@form"></p:menuitem>
				<p:menuitem value="Edit Project Perdiems" actionListener="#{projectPerdiemsBean.buttonChangeListner}" update="@form"></p:menuitem>
				<p:menuitem value="View Project Perdiems" actionListener="#{projectPerdiemsBean.buttonChangeListner}" update="@form"></p:menuitem>
					
			</p:menuButton>
					
					
		</h:panelGrid>
	   
		
		<br />
		
		
         <h:panelGrid rendered="#{projectPerdiemsBean.createPerdiemRequestForm}">
         
					<p:spacer />
				
 			<!-- 	
 			<h:panelGrid columns="3" 
						columnClasses="grid96pxCellMiddleLeftAligned, gridCellMiddleLeftAligned, gridCellMiddleLeftAligned, grid96pxCellMiddleLeftAligned, gridCellMiddleLeftAligned, gridCellMiddleLeftAligned, grid96pxCellMiddleLeftAligned, gridCellMiddleLeftAligned, gridCellMiddleLeftAligned "
						style="width: 100%">  
					
            </h:panelGrid>
             -->
            <p:outputPanel> 
            <h:panelGrid rendered="#{projectPerdiemsBean.projecAssignmentsListRender}">
            <p:scrollPanel style="width:830px;">
             <p:dataTable value="#{projectPerdiemsBean.projectAssignmentList}" var="projectAssignment" paginator="true" rows="10"  
                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                 rowsPerPageTemplate="5,10,15">  
  
            <p:column> 
        <f:facet name="header">
            <h:outputText value="Project Assignment ID" />  
        </f:facet> 
            <h:outputText value="#{projectAssignment.projectAssignmentCode}" />  
        </p:column>  
  
        <p:column>  
        <f:facet name="header">
            <h:outputText value="Client Name" />  
        </f:facet> 
            <h:outputText value="#{projectAssignment.project.client}" />  
        </p:column>  
  
        <p:column>  
         <f:facet name="header">
            <h:outputText value="Client Location" />  
        </f:facet> 
            <h:outputText value="#{projectAssignment.project.clientLocation}" />  
        </p:column>  
  
        <p:column> 
        <f:facet name="header">
            <h:outputText value="Request Date" />  
        </f:facet> 
            <h:outputText value="#{projectAssignment.project.createDate}" />  
        </p:column>  
        
         <p:column>  
         <f:facet name="header">
            <h:outputText value="Period From" />  
        </f:facet> 
            <h:outputText value="#{projectAssignment.project.periodFrom}" >
            <f:convertDateTime pattern="dd/MM/yyyy"/>  
            </h:outputText>
        </p:column>  
        
        <p:column>  
        <f:facet name="header">
            <h:outputText value="Period To" />  
        </f:facet> 
            <h:outputText value="#{projectAssignment.project.periodTo}" >
             <f:convertDateTime pattern="dd/MM/yyyy"/>  
            </h:outputText>  
        </p:column>
        <p:column> 
         <f:facet name="header">
            <h:outputText value="Recommender Status" />  
        </f:facet>  
            <h:outputText value="#{projectAssignment.recommendationStatus}" />  
        </p:column>
        <p:column>
        <f:facet name="header">
            <h:outputText value="Approver Status" />  
        </f:facet>   
            <h:outputText value="#{projectAssignment.approvalStatus}" />  
        </p:column>
       
   
        
        <p:column style="width:100px">  
                <f:facet name="header">  
                    <h:outputText value="Create" />  
                </f:facet>  
                <p:commandButton action="#{projectPerdiemsBean.createProjectPerdiemFormAction}" value="Create Perdiems"  disabled="#{projectAssignment.recommendationStatus eq 'INPROCESS'}">			
					<f:param id="projectAssignmentId" name="projectAssignmentId" value="#{projectAssignment.projectAssignmentCode}" />
					<f:param id="employeeId" name="employeeId" value="#{projectPerdiemsBean.wamUser.employee.employeeCode}" />
					
				</p:commandButton>
				
        </p:column>    
        
  
        </p:dataTable>  
        
      </p:scrollPanel>
        </h:panelGrid>
        <h:panelGrid rendered="#{projectPerdiemsBean.PROJECTASSIGNMENTSLIST_NOT_FOUND}">
			      <h:outputLabel value="No project assignments to claim perdiems" style="color:red;font-size:16px;"/>
		 </h:panelGrid>
        
        </p:outputPanel>   
      
      </h:panelGrid>
      <!-- SELECT PERDIEM ID TO EDIT -->
       <h:panelGrid id="perdiemForm" rendered="#{projectPerdiemsBean.projectPerdiemsListRenderer}">
         
        
           
             <p:dataTable  value="#{projectPerdiemsBean.projectPerdiemsList}" var="projectPerdiem" paginator="true" rows="10"  
                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                 rowsPerPageTemplate="5,10,15">  
  
            <p:column> 
        <f:facet name="header">
            <h:outputText value="Project Perdiem Code" />  
        </f:facet> 
            <h:outputText value="#{projectPerdiem.projectPerdiemCode}" />  
        </p:column>  
  
        <p:column>  
        <f:facet name="header">
            <h:outputText value="Requested Date" />  
        </f:facet> 
            <h:outputText value="#{projectPerdiem.requestDate}">
             <f:convertDateTime pattern="dd/MM/yyyy"/>
            </h:outputText>  
        </p:column>  
  
        <p:column>  
         <f:facet name="header">
            <h:outputText value="Project Name" />  
        </f:facet> 
            <h:outputText value="#{projectPerdiem.projectAssignment.project.projectName}" />  
        </p:column>  
  
        <p:column> 
        <f:facet name="header">
            <h:outputText value="Clien Name" />  
        </f:facet> 
            <h:outputText value="#{projectPerdiem.projectAssignment.project.client}" />  
        </p:column>  
        
         <p:column>  
         <f:facet name="header">
            <h:outputText value="Project Period From" />  
        </f:facet> 
            <h:outputText value="#{projectPerdiem.projectAssignment.project.periodFrom}" >
            <f:convertDateTime pattern="dd/MM/yyyy"/>  
            </h:outputText>
        </p:column>  
        
        <p:column>  
        <f:facet name="header">
            <h:outputText value="Project Period To" />  
        </f:facet> 
            <h:outputText value="#{projectPerdiem.projectAssignment.project.periodTo}" >
             <f:convertDateTime pattern="dd/MM/yyyy"/>  
            </h:outputText>  
        </p:column>
   
      
   
        
        <p:column style="width:100px" rendered="#{projectPerdiemsBean.selectedButton eq 'Edit Project Perdiems'}">  
                <f:facet name="header">  
                    <h:outputText value="Edit" />  
                </f:facet>  
                <p:commandButton action="#{projectPerdiemsBean.editProjectPerdiemFormAction}" value="Edit"  disabled="#{projectPerdiem.projectAssignment.recommendationStatus ne 'RECOMMENDED'}" >			
					<f:param id="projectPerdiemCode" name="projectPerdiemCode" value="#{projectPerdiem.projectPerdiemCode}" />
					<f:param id="employeeId" name="employeeId" value="#{projectPerdiem.employee.employeeCode}" />
					<f:param id="revision" name="revision" value="#{projectPerdiemsBean.revision}" />
					<f:param id="projectAssignmentId" name="projectAssignmentId" value="#{projectPerdiem.projectAssignment.projectAssignmentCode}" />
				</p:commandButton>
				
        </p:column>    
           
        <p:column style="width:100px" rendered="#{projectPerdiemsBean.selectedButton eq 'View Project Perdiems'}">  
                <f:facet name="header">  
                    <h:outputText value="View" />  
                </f:facet>  
              
				
				 <p:commandButton action="#{projectPerdiemsBean.viewAndPrintProjectPerdiemFormAction}" value="View"  disabled="#{projectPerdiem.projectAssignment.recommendationStatus ne 'RECOMMENDED'}" rendered="#{projectPerdiemsBean.selectedButton eq 'View Project Perdiems'}">			
					<f:param id="projectPerdiemCodeView" name="projectPerdiemCode" value="#{projectPerdiem.projectPerdiemCode}" />
					<f:param id="employeeIdView" name="employeeId" value="#{projectPerdiem.employee.employeeCode}" />
					<f:param id="revisionView" name="revision" value="#{projectPerdiemsBean.revision}" />
					<f:param id="projectAssignmentIdView" name="projectAssignmentId" value="#{projectPerdiem.projectAssignment.projectAssignmentCode}" />
				</p:commandButton>
        </p:column>    
        
  
        </p:dataTable>  
     
        
        </h:panelGrid>
         
         <h:panelGrid rendered="#{projectPerdiemsBean.PERDIEMLIST_NOT_FOUND}">
			      <h:outputLabel value="No project perdiems created." style="color:red;font-size:16px;"/>
			</h:panelGrid>
        
        
         
		</h:form>
		
	</ui:define>
</ui:composition>

